<html>

<head>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">
<meta name="Template"
content="C:\PROGRAM FILES\MICROSOFT OFFICE\OFFICE\html.dot">
<meta name="GENERATOR" content="Microsoft FrontPage Express 2.0">
<title></title>
</head>

<body bgcolor="#FFFF99" link="#0000FF" vlink="#800080">

<p align="center"><font size="4" face="Arial"><b>FAQ for regex++ </b></font></p>

<p align="center"><i>(version 2.22)</i></p>

<p>&nbsp;</p>

<p><font color="#FF0000">Q. Configure says that my compiler is
unable to merge template instances, what does this mean?</font></p>

<p>A. When you compile template code, you can end up with the
same template instances in multiple translation units - this will
lead to link time errors unless your compiler/linker is smart
enough to merge these template instances into a single record in
the executable file. If you see this warning after running
configure, then you can still link to libregex++.a if:</p>

<ol>
    <li>You use only the low-level template classes (reg_expression&lt;&gt;
        reg_match&lt;&gt; etc), from a single translation unit,
        and use no other part of regex++.</li>
    <li>You use only the POSIX API functions (regcomp regexec etc),
        and no other part of regex++.</li>
    <li>You use only the high level class RegEx, and no other
        part of regex++.</li>
</ol>

<p>Another option is to create a master include file, which #include's
all the regex++ source files, and all the source files in which
you use regex++. You then compile and link this master file as a
single translation unit.</p>

<p><font color="#FF0000">Q. Configure says that my compiler is
unable to merge template instances from archive files, what does
this mean?</font></p>

<p>A. When you compile template code, you can end up with the
same template instances in multiple translation units - this will
lead to link time errors unless your compiler/linker is smart
enough to merge these template instances into a single record in
the executable file. Some compilers are able to do this for
normal .cpp or .o files, but fail if the object file has been
placed in a library archive. If you see this warning after
running configure, then you can still link to libregex++.a if:</p>

<ol>
    <li>You use only the low-level template classes (reg_expression&lt;&gt;
        reg_match&lt;&gt; etc), and use no other part of regex++.</li>
    <li>You use only the POSIX API functions (regcomp regexec etc),
        and no other part of regex++.</li>
    <li>You use only the high level class RegEx, and no other
        part of regex++.</li>
</ol>

<p>Another option is to add the regex++ source files directly to
your project instead of linking to libregex++.a, generally you
should do this only if you are getting link time errors with
libregex++.a.</p>

<p><font color="#FF0000">Q. Configure says that my compiler can't
merge templates containing switch statements, what does this mean?</font></p>

<p>A. Some compilers can't merge templates that contain static
data - this includes switch statements which implicitly generate
static data as well as code. Principally this affects the egcs
compiler - but note gcc 2.81 also suffers from this problem - the
compiler will compile and link the code - but the code will not
run because the code and the static data it uses have become
separated. The default behaviour of regex++ is to try and fix
this problem by declaring &quot;problem&quot; templates inside
unnamed namespaces, so that the templates have internal linkage.
Note that this can result in a great deal of code bloat. If the
compiler doesn't support namespaces, or if code bloat becomes a
problem, then follow the guidelines above for placing all the
templates used in a single translation unit, and edit jm_opt.h so
that JM_NO_TEMPLATE_SWITCH_MERGE is no longer defined.</p>

<p><font color="#FF0000">Q. I can't get regex++ to work with
escape characters, what's going on?</font></p>

<p>A. If you embed regular expressions in C++ code, then remember
that escape characters are processed twice: once by the C++
compiler, and once by the regex++ expression compiler, so to pass
the regular expression \d+ to regex++, you need to embed &quot;\\d+&quot;
in your code. Likewise to match a literal backslash you will need
to embed &quot;\\\\&quot; in your code.</p>

<p><font color="#FF0000">Q. Why don't character ranges work
properly?<br>
</font>A. The POSIX standard specifies that character range
expressions are locale sensitive - so for example the expression
[A-Z] will match any collating element that collates between 'A'
and 'Z'. That means that for most locales other than &quot;C&quot;
or &quot;POSIX&quot;, [A-Z] would match the single character 't'
for example, which is not what most people expect - or at least
not what most people have come to expect from regular expression
engines. For this reason, the default behaviour of regex++ is to
turn locale sensitive collation off by setting the regbase::nocollate
compile time flag (this is set by regbase::normal). However if
you set a non-default compile time flag - for example regbase::extended
or regbase::basic, then locale dependent collation will be
enabled, this also applies to the POSIX API functions which use
either regbase::extended or regbase::basic internally, in the
latter case use REG_NOCOLLATE in combination with either REG_BASIC
or REG_EXTENDED when invoking regcomp if you don't want locale
sensitive collation. <i>[Note - when regbase::nocollate in effect,
the library behaves &quot;as if&quot; the LC_COLLATE locale
category were always &quot;C&quot;, regardless of what its
actually set to - end note</i>].</p>

<p><font color="#FF0000">&nbsp;Q. Why can't I use the &quot;convenience&quot;
versions of query_match/reg_search/reg_grep/reg_format/reg_merge?</font></p>

<p>A. These versions may or may not be available depending upon
the capabilities of your compiler, the rules determining the
format of these functions are quite complex - and only the
versions visible to a standard compliant compiler are given in
the help. To find out what your compiler supports, run &lt;regex&gt;
through your C++ pre-processor, and search the output file for
the function that you are interested in.</p>

<p><font color="#FF0000">Q. Why don't the sub_match&lt;&gt;
conversion operators throw an exception - even when I'm expecting
one.</font></p>

<p>A. Whether these functions actually throw std::bad_cast if the
conversion is not possible depends upon the capabilities of your
C++ standard library.</p>

<p><font color="#FF0000">Q. Why are there no throw specifications
on any of the functions? What exceptions can the library throw?</font></p>

<p>A. Not all compilers support (or honour) throw specifications,
others support them but with reduced efficiency. Throw
specifications may be added at a later date as compilers begin to
handle this better. The library should throw only three types of
exception: jm::bad_expression can be thrown by reg_expression
when compiling a regular expression if the flag regbase::use_except
is set; std::bad_cast can be thrown by the class sub_match's
conversion operators; finally std::bad_alloc can be thrown by
just about any of the functions in this library.</p>

<p>&nbsp;</p>
</body>
</html>
